package com.shengde.jinwawaforleader.model.myJob.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;

import com.bumptech.glide.Glide;
import com.shengde.jinwawaforleader.R;
import com.shengde.jinwawaforleader.model.myJob.classStatus.ClassStatusItemDetailActivity;
import com.shengde.jinwawaforleader.network.BaseProtocol;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by Administrator on 2016/12/7 0007.
 */
public class ImageGridAdapter extends BaseAdapter{
	private List<String> img_list;
	private Context context;

	public ImageGridAdapter(Context context, List<String> img_list) {
		this.context =context;
		this.img_list = img_list;
	}

	@Override
	public int getCount() {
		// TODO Auto-generated method stub
		return img_list.size();
	}

	@Override
	public Object getItem(int position) {
		// TODO Auto-generated method stub
		return img_list.get(position);
	}

	@Override
	public long getItemId(int position) {
		// TODO Auto-generated method stub
		return position;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		// TODO Auto-generated method stub
		Holder holder;
		if (convertView == null) {
			holder = new Holder();
			convertView = LayoutInflater.from(context)
					.inflate(R.layout.imggrid_item, null);
			holder.img_grid = (ImageView) convertView
					.findViewById(R.id.imageView_imglist_item);
			convertView.setTag(holder);
		} else {
			holder = (Holder) convertView.getTag();
		}
		Glide.with(context)
				.load(BaseProtocol.IMG_BASE + img_list.get(position))
				.into(holder.img_grid);
		return convertView;
	}
}

class Holder {
	ImageView img_grid;
}
